﻿<%@ Page Title="Phân quyền quản trị" Language="vb" AutoEventWireup="false" MasterPageFile="~/Master/InSite.Master" CodeBehind="PmsManager.aspx.vb" Inherits="Core.PmsManager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<script language="javascript" type="text/javascript">
    var lengtview = 30;
    function CheckGroup(obj, val, grdid, objid) {
        var chkbox;
        var i = 2;
        if (i < 10) {
            chkbox = document.getElementById(grdid + '_ctl0' + i + '_' + objid);
        }
        else {
            chkbox = document.getElementById(grdid + '_ctl' + i + '_' + objid);
        }
        for (var k = 0; k < lengtview; k++) {
            if (chkbox != null) {
                if (chkbox.getAttribute("group") == val) {
                    if (obj.checked) {
                        chkbox.checked = true;
                    }
                    else {
                        chkbox.checked = false;
                    }
                }
            }
            i = i + 1;
            if (i < 10) {
                chkbox = document.getElementById(grdid + '_ctl0' + i + '_' + objid);
            }
            else {
                chkbox = document.getElementById(grdid + '_ctl' + i + '_' + objid);
            }
        }
    }
    function DGSelectOrUnselectAll(grdid, obj, objlist) {
        //this function decides whether to check or uncheck all 
        if (obj.checked)
            DGSelectAll(grdid, objlist, 1, lengtview)
        else
            DGSelectAll(grdid, objlist, 0, lengtview)
    }
    //----------
    function DGSelectAll(grdid, objid, check, lengtview) {
        //.this function is to check all the items
        var chkbox;
        var i = 2;
        if (i < 10) {
            chkbox = document.getElementById(grdid + '_ctl0' + i + '_' + objid);
        }
        else {
            chkbox = document.getElementById(grdid + '_ctl' + i + '_' + objid);
        }
        //while (chkbox != null) 
        for (var k = 0; k < lengtview; k++) {
            if (chkbox != null) {
                if (check == 1) {
                    chkbox.checked = true;
                }
                else {
                    chkbox.checked = false;
                }
            }
            i = i + 1;
            if (i < 10) {
                chkbox = document.getElementById(grdid + '_ctl0' + i + '_' + objid);
            }
            else {
                chkbox = document.getElementById(grdid + '_ctl' + i + '_' + objid);
            }
        }
    }
    function DGCheckOne(grdid, obj, objlist) {
        var chkbox;
        var i = 2;
        if (i < 10) {
            chkbox = document.getElementById(grdid + '_ctl0' + i + '_' + objlist);
        }
        else {
            chkbox = document.getElementById(grdid + '_ctl' + i + '_' + objlist);
        }
        while (chkbox != null) {
            chkbox.checked = false;
            i = i + 1;
            if (i < 10) {
                chkbox = document.getElementById(grdid + '_ctl0' + i + '_' + objlist);
            }
            else {
                chkbox = document.getElementById(grdid + '_ctl' + i + '_' + objlist);
            }
        }
        obj.checked = true;
    }
</script>
    <fieldset>
        <legend>Danh sách người dùng</legend>
		    <asp:SqlDataSource ID="dsSourceUser" runat="server"></asp:SqlDataSource>
    <asp:GridView ID="gridUser" runat="server" DataSourceID="dsSourceUser" class="tblMain" 
            AutoGenerateColumns="false" GridLines="None" AllowPaging="True" DataKeyNames="UserID"
            PageSize="30" HeaderStyle-BackColor="#9097a9">
            <Columns>
                <asp:TemplateField HeaderText="No.">
                    <ItemTemplate>
                        <asp:Label Visible="false" runat="server" ID="lbl_ID" Text='<%#Eval("UserID") %>'></asp:Label>
                        <asp:Label runat="server" ID="lblSTT" Text='<%#Container.DataItemIndex + 1 %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle Width="50px" HorizontalAlign="Left" />
                    <ItemStyle Width="50px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Username">
                    <ItemTemplate>
                        <asp:Label ID="lbUserName" runat="server" Text='<%#Eval("UserName") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle Width="150px" HorizontalAlign="Left" />
                    <ItemStyle Width="150px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Full name">
                    <ItemTemplate>
                        <asp:Label ID="lbFullName" runat="server" Text='<%#Eval("UserFullName") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle Width="150px" HorizontalAlign="Left" />
                    <ItemStyle Width="150px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Status">
                    <ItemTemplate>
                        <asp:Label ID="lbUserStt" runat="server" Text='<%#getStt(Eval("UserStt")) %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle Width="150px" HorizontalAlign="Left" />
                    <ItemStyle Width="150px" />
                </asp:TemplateField>
            </Columns>
        <PagerStyle HorizontalAlign="Center" />
    </asp:GridView>
    </fieldset>
    <br />
    <div class="center">
        <asp:Button ID="btnUpdate" runat="server" Text="Update" Width="60" CssClass="hand"/>
        <asp:Button ID="btnBack" runat="server" Text="Quay lại" Width="60" CssClass="hand"/>
    </div>
    
 
 <fieldset>
        <legend>Bảng phân quyền</legend>
		    <asp:SqlDataSource ID="dsSourcePms" runat="server"></asp:SqlDataSource>
    <asp:GridView ID="gridPms" runat="server" DataSourceID="dsSourcePms" class="tblMain" 
            AutoGenerateColumns="false" GridLines="None" AllowPaging="True" 
            PageSize="30" HeaderStyle-BackColor="#9097a9">
            <Columns>
                <asp:TemplateField HeaderText="No.">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text="<%#Container.DataItemIndex + 1%>"></asp:Label>
                        <!--<asp:Label ID="lbID" runat="server" Visible="true" Text='<%#Eval("MenuID") %>'></asp:Label>-->
                    </ItemTemplate>
                    <HeaderStyle Width="50px" HorizontalAlign="center" />
                    <ItemStyle Width="50px" HorizontalAlign="center" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Page Function">
                    <ItemTemplate>
                        <asp:Label ID="lbUserName" runat="server" Text='<%#formatName(Eval("MenuCode"),Eval("MenuPageName")) %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle Width="150px" HorizontalAlign="center" />
                    <ItemStyle Width="150px"  HorizontalAlign="center"/>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="View">
                    <HeaderTemplate>
                        <asp:Label ID="lblAccess" runat="server" Text="Xem"></asp:Label><br />
                        <span><input class="inputChk" type="checkbox" id="chkViewAll" onclick="DGSelectOrUnselectAll('ctl00_ContentPlaceHolder1_gridPms',this,'chkView')"/> <labelChk></labelChk></span>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lbCode" runat="server" Text='<%#Eval("MenuCode") %>' Visible="false"></asp:Label>
                    <span><input class="inputChk" type="checkbox" id="chkView" checked='<%#formatBool(Eval("PmsView")) %>' runat="server" /> <labelChk></labelChk></span>
                    </ItemTemplate>
                    <HeaderStyle Width="50px" HorizontalAlign="center" />
                    <ItemStyle Width="50px" HorizontalAlign="center" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Update">
                    <HeaderTemplate>
                        <asp:Label ID="lblAccess" runat="server" Text="Update"></asp:Label><br />
                        <span><input class="inputChk" type="checkbox" id="chkUpdateAll" onclick="DGSelectOrUnselectAll('ctl00_ContentPlaceHolder1_gridPms',this,'chkUpdate')"/> <labelChk></labelChk></span>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <span><input class="inputChk" type="checkbox" id="chkUpdate" checked='<%#formatBool(Eval("PmsUpdate")) %>' runat="server" /> <labelChk></labelChk></span>
                    </ItemTemplate>
                    <HeaderStyle Width="50px" HorizontalAlign="center" />
                    <ItemStyle Width="50px" HorizontalAlign="center" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Delete">
                    <HeaderTemplate>
                        <asp:Label ID="lblAccess" runat="server" Text="Delete"></asp:Label><br />
                        <span><input class="inputChk" type="checkbox" id="chkDeleteAll" onclick="DGSelectOrUnselectAll('ctl00_ContentPlaceHolder1_gridPms',this,'chkDelete')"/> <labelChk></labelChk></span>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <span><input class="inputChk" type="checkbox" id="chkDelete" checked='<%#formatBool(Eval("PmsDelete")) %>' runat="server" /> <labelChk></labelChk></span>
                    </ItemTemplate>
                    <HeaderStyle Width="50px" HorizontalAlign="center" />
                    <ItemStyle Width="50px" HorizontalAlign="center" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Status">
                    <ItemTemplate>
                        <span><input class="inputChk" type="checkbox" id="chkStt" checked='<%#formatBool(Eval("MenuStt")) %>' runat="server" style="margin-left: -115px;"/> <labelChk style="margin-left: 100px;"></labelChk></span>
                    </ItemTemplate>
                    <HeaderStyle Width="150px" HorizontalAlign="center" />
                    <ItemStyle Width="150px" HorizontalAlign="center" />
                </asp:TemplateField>
            </Columns>
        <PagerStyle HorizontalAlign="Center" />
    </asp:GridView>
				
				
				
    </fieldset>

</asp:Content>
